package com.ruoyi.fun.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fun.mapper.EcUserAddressMapper;
import com.ruoyi.fun.domain.EcUserAddress;
import com.ruoyi.fun.service.IEcUserAddressService;

/**
 * 收货地址Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class EcUserAddressServiceImpl implements IEcUserAddressService 
{
    @Autowired
    private EcUserAddressMapper ecUserAddressMapper;

    /**
     * 查询收货地址
     * 
     * @param addressId 收货地址主键
     * @return 收货地址
     */
    @Override
    public EcUserAddress selectEcUserAddressByAddressId(Long addressId)
    {
        return ecUserAddressMapper.selectEcUserAddressByAddressId(addressId);
    }

    /**
     * 查询收货地址列表
     * 
     * @param ecUserAddress 收货地址
     * @return 收货地址
     */
    @Override
    public List<EcUserAddress> selectEcUserAddressList(EcUserAddress ecUserAddress)
    {
        return ecUserAddressMapper.selectEcUserAddressList(ecUserAddress);
    }

    /**
     * 新增收货地址
     * 
     * @param ecUserAddress 收货地址
     * @return 结果
     */
    @Override
    public int insertEcUserAddress(EcUserAddress ecUserAddress)
    {
        ecUserAddress.setCreateTime(DateUtils.getNowDate());
        return ecUserAddressMapper.insertEcUserAddress(ecUserAddress);
    }

    /**
     * 修改收货地址
     * 
     * @param ecUserAddress 收货地址
     * @return 结果
     */
    @Override
    public int updateEcUserAddress(EcUserAddress ecUserAddress)
    {
        ecUserAddress.setUpdateTime(DateUtils.getNowDate());
        return ecUserAddressMapper.updateEcUserAddress(ecUserAddress);
    }

    /**
     * 批量删除收货地址
     * 
     * @param addressIds 需要删除的收货地址主键
     * @return 结果
     */
    @Override
    public int deleteEcUserAddressByAddressIds(Long[] addressIds)
    {
        return ecUserAddressMapper.deleteEcUserAddressByAddressIds(addressIds);
    }

    /**
     * 删除收货地址信息
     * 
     * @param addressId 收货地址主键
     * @return 结果
     */
    @Override
    public int deleteEcUserAddressByAddressId(Long addressId)
    {
        return ecUserAddressMapper.deleteEcUserAddressByAddressId(addressId);
    }

    /**
     * 更新用户默认地址
     * 
     * @param userId 用户ID
     * @param excludeAddressId 排除的地址ID（新的默认地址ID）
     * @return 结果
     */
    @Override
    public int updateUserDefaultAddress(Long userId, Long excludeAddressId)
    {
        return ecUserAddressMapper.updateUserDefaultAddress(userId, excludeAddressId);
    }

    /**
     * 根据用户ID获取默认地址
     * 
     * @param userId 用户ID
     * @return 默认地址
     */
    @Override
    public EcUserAddress selectDefaultAddressByUserId(Long userId)
    {
        return ecUserAddressMapper.selectDefaultAddressByUserId(userId);
    }

    /**
     * 根据addressId和用户ID查询UserAddress
     * 
     * @param addressId UserAddress主键
     * @param userId 用户ID
     * @return UserAddress
     */
    @Override
    public EcUserAddress selectEcUserAddressByAddressIdAndUserId(Long addressId, Long userId)
    {
        return ecUserAddressMapper.selectEcUserAddressByAddressIdAndUserId(addressId, userId);
    }

    /**
     * 根据组织ID查询UserAddress列表
     * 
     * @param ecuseraddress UserAddress
     * @param orgId 组织ID
     * @return UserAddress集合
     */
}